package com.tong.lib_base.ft_home.service.impl;

import android.content.Context;

import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.launcher.ARouter;
import com.tong.lib_base.ft_home.service.HomeService;

/**
 * author:liuzhitong
 * date:2022/3/2
 * description:
 */
public class HomeImpl {
    /**
     * ARouter的自动注入
     * （自动接线）
     */
    @Autowired(name = "/home/home_service")
    protected HomeService mHomeService;

    private static HomeImpl mHomeImpl = null;

    public static HomeImpl getInstance() {
        if (mHomeImpl == null) {
            synchronized (HomeImpl.class){
                if(mHomeImpl == null){
                    mHomeImpl = new HomeImpl();
                }
            }
        }
        return mHomeImpl;
    }
    //必须有这句话，和eventbus类似
    public HomeImpl(){
        ARouter.getInstance().inject(this);
    }
    public Fragment getFragment(Context context){
        return mHomeService.getFragment(context);
    }
}
